﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections.ObjectModel;

namespace BesAsm.Stormwater.Swmm5Results
{
  public class LinkVariables : ResultVariablesBase, IName
  {
    public ResultVariable FlowRate = new ResultVariable("FlowRate", 0);
    public ResultVariable FlowDepth = new ResultVariable("FlowDepth", 4);
    public ResultVariable Velocity = new ResultVariable("Velocity", 8);
    public ResultVariable FroudeNumber = new ResultVariable("FroudeNumber", 12);
    public ResultVariable Capacity = new ResultVariable("Capacity", 16);    

    public float LinkType { get; internal set; }
    public float UsInvertOffset { get; internal set; }
    public float DsInvertOffset { get; internal set; }
    public float MaxDepth { get; internal set; }
    public float Length { get; internal set; }
    
    public LinkVariables(string name, OutputFileReader reader)
    {
      _reader = reader;
      _name = name;
      _variables.Add(FlowRate);
      _variables.Add(FlowDepth);
      _variables.Add(Velocity);
      _variables.Add(FroudeNumber);
      _variables.Add(Capacity);      
    }

    protected override int GetElementPosition()
    {
      return _reader.LinkPosition[Name];
    }

    public void LoadFlowRate(bool close)
    {
      FlowRate.SetData(
        LoadResult(FlowRate.Position, close));
      FlowRate.IsLoaded = true;
    }
    public void LoadFlowDepth(bool close)
    {
      FlowDepth.SetData(
      LoadResult(FlowDepth.Position, close));
      FlowDepth.IsLoaded = true;    
    }
    public void LoadFlowVelocity(bool close)
    {
      Velocity.SetData(
      LoadResult(Velocity.Position, close));
      Velocity.IsLoaded = true;        
    }
    public void LoadFroudeNumber(bool close)
    {
      FroudeNumber.SetData(
        LoadResult(FroudeNumber.Position, close));
      FroudeNumber.IsLoaded = true;         
    }
    public void LoadCapacity(bool close)
    {
      Capacity.SetData(
        LoadResult(Capacity.Position, close));
      Capacity.IsLoaded = true;       
    }

  }
      
}
